package com.zysc.processflow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zysc.processflow.common.util.StringUtils;
import com.zysc.processflow.entity.Role;
import com.zysc.processflow.mapper.RoleMapper;
import com.zysc.processflow.service.IRoleService;
import com.zysc.processflow.common.base.BaseService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author 正元智慧城市_
 * @since 2023-02-20
 */
@Service
public class RoleServiceImpl extends BaseService<RoleMapper, Role> implements IRoleService {

    @Override
    public List<Role> GetRolePermission(IPage<Role> page, String rolename) {
        LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .like(!StringUtils.isNull(rolename), Role::getRolename, rolename);
        List<Role> list = new ArrayList<>();
        if (page != null) {
            list = this.baseMapper.selectPage(page, queryWrapper).getRecords();
        } else {
            list = this.baseMapper.selectList(queryWrapper);
        }
        return list;
    }
}
